package com.yanqu.road.server.cmd.activity.curio;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cangbao.CurioProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.curio.CurioConfigMgr;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

@Cmd(code = Protocol.S_CURIO_HISTORY_MAX_SCORE_GET_USER_INFO, desc = "藏品最先达到档位信息上传(来自跨服通知)")
public class CurioItemMaxScoreHistoryGetCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        CurioProto.CurioItemMaxScoreGetReqMsg reqMsg = CurioProto.CurioItemMaxScoreGetReqMsg.parseFrom(packet.getBytes());
        int itemId = reqMsg.getItemId();
        List<Integer> conditionList = CurioConfigMgr.getConditionList(itemId);
        if(conditionList.size() == 0){
            player.sendPacket(Protocol.U_CURIO_HISTORY_MAX_SCORE_GET_USER_INFO, CurioProto.CurioItemMaxScoreGetRespMsg.newBuilder().setRet(0));
            return;
        }
        CurioProto.CrossCurioItemMaxScoreGetReqMsg.Builder crossReq = CurioProto.CrossCurioItemMaxScoreGetReqMsg.newBuilder();
        crossReq.addAllConditionId(conditionList);
        player.sendPacket(Protocol.C_CURIO_HISTORY_MAX_SCORE_GET_USER_INFO, crossReq);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
